package com.jinglvhuanjing.app.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.jinglvhuanjing.app.R;
import com.jinglvhuanjing.app.bean.param.ParamLayout3Bean;

import java.util.ArrayList;
import java.util.HashMap;

public class ParamSettingRow3View extends ConstraintLayout {
    public ParamSettingRow3View(@NonNull Context context) {
        super(context);
        this.init(context);
    }

    public ParamSettingRow3View(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.init(context);
    }

    public ParamSettingRow3View(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.init(context);
    }

    /*** 满溢限值 ***/
    private ParamSettingTermView myxz;
    /*** 电机限值 ***/
    private ParamSettingTermView djxz;
    /*** 延时时间 ***/
    private ParamSettingTermView yssj;
    /*** 投口类型 ***/
    private ParamSettingSpinnerView tklx;

    /*** 环境监测 - 臭气值 ***/
    private CustomTextView hjzl_cqz;
    /*** 环境监测 - 温度值 ***/
    private CustomTextView hjzl_wdz;
    /*** 环境监测 - 湿度值 ***/
    private CustomTextView hjzl_sdz;

    private void init(Context context) {
        setClipChildren(false);
        LayoutInflater.from(context).inflate(R.layout.view_params_setting_row_3_layout, this, true);
        this.myxz = findViewById(R.id.param_setting_term_myxz);
        this.djxz = findViewById(R.id.param_setting_term_djxz);
        this.yssj = findViewById(R.id.param_setting_term_yssj);
        this.tklx = findViewById(R.id.param_setting_term_tklx);
        this.hjzl_cqz = findViewById(R.id.hjzl_cqz);
        this.hjzl_wdz = findViewById(R.id.hjzl_wdz);
        this.hjzl_sdz = findViewById(R.id.hjzl_sdz);

        this.myxz.setLabel("满溢限值");
        this.djxz.setLabel("电机限制");
        this.yssj.setLabel("延时时间");
        this.tklx.setLabel("投口类型");

        this.myxz.setParamTag("参数设置_满溢限值", ParamLayout3Bean.PARAM_KEY_CSSZ_MYXZ);
        this.djxz.setParamTag("参数设置_电机限制", ParamLayout3Bean.PARAM_KEY_CSSZ_DJXZ);
        this.yssj.setParamTag("参数设置_延时时间", ParamLayout3Bean.PARAM_KEY_CSSZ_YSSJ);
        this.tklx.setParamTag("参数设置_投口类型", ParamLayout3Bean.PARAM_KEY_CSSZ_TKLX);

        this.hjzl_cqz.setParamTag("环境监测_臭气值", ParamLayout3Bean.PARAM_KEY_hjzl_cqz);
        this.hjzl_wdz.setParamTag("环境监测_温度值", ParamLayout3Bean.PARAM_KEY_hjzl_wdz);
        this.hjzl_sdz.setParamTag("环境监测_湿度值", ParamLayout3Bean.PARAM_KEY_hjzl_sdz);

        this.myxz.setTkVisible(true);
    }

    /**
     * 获取值
     *
     * @return 集合
     */
    public ArrayList<HashMap<String, String>> getFormValue() {
        ArrayList<HashMap<String, String>> values = new ArrayList<>();
        values.addAll(this.myxz.getValue());
        values.addAll(this.djxz.getValue());
        values.addAll(this.yssj.getValue());
        values.addAll(this.tklx.getValue());
        values.add(this.hjzl_cqz.getValueMap());
        values.add(this.hjzl_wdz.getValueMap());
        values.add(this.hjzl_sdz.getValueMap());
        return values;
    }
}
